package com.cwm.comsumer;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Service;

import java.util.function.Consumer;

@Slf4j
@Service
public class SmsConsumerService {
 
	/**
	 * 函数式编辑接收消息  sms名称与 spring.cloud.stream.founction.definition 中的一致。
	 *
	 * @return
	 */
	@Bean
	public Consumer<Message<String>> sms() {
		return message -> {
			log.info("消费消息为：{}", message);
			System.out.println("消费消息为"+ message.getPayload().toString());
		};
	}
}